﻿using System.Security.Cryptography;
using System.Text;

namespace DemoWebapi01.Helper
{
    public class CommonHelper
    {
        /// <summary>
        /// 64位的MD5加密
        /// </summary>
        /// <param name="password"></param>
        /// <returns></returns>
        public static string MD5Encrypt64(string password)
        {
            string cl = password;
            //string pwd = "";
            MD5 md5 = MD5.Create(); //实例化一个md5对像
            // 加密后是一个字节类型的数组，这里要注意编码UTF8/Unicode等的选择　
            byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(cl));
            return Convert.ToBase64String(s);
        }

        public static async Task<string> RandomNickName()
        {
            using HttpClient httpClient = new HttpClient();
            var response = await httpClient.GetAsync("https://api.mir6.com/api/sjname");
            var res = await response.Content.ReadAsStringAsync();
            return res;
        }

    }
}
